--法律专精
local falvzhuangjing = fk.CreateSkill {
    name = "mcdh_falvzhuangjing",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

falvzhuangjing:addEffect(fk.StartPindian,{
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(self) or player:usedSkillTimes(self.name, Player.HistoryTurn) >= 1 then return false end
        if target == player or table.contains(data.tos, player) then
            return player:getHandcardNum() > 1
        end
        return not player:isKongcheng()
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = { target.id }
        table.insertTableIfNeed(targets, table.map(data.tos, Util.IdMapper))
        table.removeOne(targets, player.id)
        local tids, cid = room:askForChooseCardAndPlayers(
                player,
                targets,
                1, 1,
                ".",
                "#mcdh_falvzhuangjing-choice",
                true
        )
        if #tids > 0 then
            self.cost_data = { tids[1], cid }
            return true
        end
        return false
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = room:getPlayerById(self.cost_data[1])
        local card = Fk:getCardById(self.cost_data[2])
        to:addToPile("mcdh_falvzhuangjing-mark", card.id, false, self.name, player, player)
        if to == data.from then
            data.fromCard = card
        else
            data.results[to] = data.results[to] or {}
            data.results[to].toCard = card
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_falvzhuangjing"] = "代讼",
    [":mcdh_falvzhuangjing"] = "『法律专精』<br>每回合限一次，当一名其他角色拼点时，你可以选择一张手牌并扣置于其武将牌上称为「律」，令其改为用此牌进行拼点。",
    ["#mcdh_falvzhuangjing-choice"] = "法律专精:为一名其他拼点角色选择一张拼点牌",
    ["mcdh_falvzhuangjing-mark"] = "律",
}

return falvzhuangjing